﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PersonaLibrary.PersonaliiReference;

namespace PersonaLibrary.ViewModel.NoteViewModel
{
    internal class NoteViewModel : ReferenceEditableItem<Note>
    {
        public NoteViewModel()
        {
            EditableItem = new Note();
        }

        public NoteViewModel(int id)
        {
			EditableItem = Context.CreateAndExecuteQuery<Note>(string.Format("Note?$filter=Id eq {0}&$expand=EmployeeNoteLink/Employee,EmployeeNoteLink", id)).Single();
        }

        public override bool CanCommit()
        {
            return !string.IsNullOrEmpty(EditableItem.Name);
        }
    }
}
